// 接口根路径（就是在每个接口前面需要加上的地址）：http://124.223.14.236:3001/api
$('form').on('submit', async function (e) {
  e.preventDefault()
  //  获取当前的值
  const username = $('#username').val()
  const password = $('#password').val()
  const phone = $('#phone').val()
  const sex = parseInt($('[name=sex]:checked').val())//必须为number类型
  const vip = parseInt($('[name=vip]:checked').val())//必须为number类型
  const question = $('#question').val()
  const answer = $('#answer').val()
  // console.log(username, password, phone, sex, vip, question, answer);

  const { data } = await axios.post('http://124.223.14.236:3001/api/user/reg', {
    username,
    password,
    phone,
    sex,
    vip,
    question,
    answer
  })
  console.log(data)
  if (!data.success) {
    return alert(data.msg)
  }
  alert('注册成功,请登录')
  location.href = '../01-loginBaseCode/login.html'

})